package sjtu.ist.warehouse4ws.action;
import java.util.ArrayList;
import java.util.List;
import sjtu.ist.warehouse4ws.service.FileInfoService;
import sjtu.ist.warehouse4ws.vo.FullSearchVO;

import org.apache.struts2.json.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

public class ShowSearchAction extends ActionSupport{
	private FileInfoService fileInfoService;
//	private List<Fileinfo> fileList = new ArrayList<Fileinfo>();
	private List<FullSearchVO> fileList = new ArrayList<FullSearchVO>();
	
	private String keyWord;
	//获得Search结果列表
	public String showSearchFileList(){
		//this.fileList = fileInfoService.getAllFullSearchResult(keyWord);
		
		this.fileList = fileInfoService.getAllFullSearchResult(keyWord);
				
		return SUCCESS;
	}
	
	//具体显示哪些内容有待修改~JSON再问问！
	@JSON(name = "totalFile")
	public int getTotalFile() {
		return this.fileList.size();
	}

	@JSON(name = "File")
	public List<FullSearchVO> getFileList() {
		return this.fileList;
	}
	
	public void setFileList(List<FullSearchVO> fileList) {
		this.fileList = fileList;
	}
	
	// 注入FileInfoService
	public void setFileInfoService(FileInfoService fileInfoService) {
		this.fileInfoService = fileInfoService;
	}

	public String getKeyWord() {
		return keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}
}